package com.example.demo.service;

import com.example.demo.dao.OrderMapper;
import com.example.demo.entity.Order;
import com.example.demo.feign.AccountClient;

import io.seata.spring.annotation.GlobalTransactional;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author renshuai
 * @since 2020-04-02
 */
@Service
@Transactional
public class OrderService extends ServiceImpl<OrderMapper, Order> implements IOrderService {
	
	@Autowired
	private OrderMapper orderMapper;
	
	@Autowired
	private AccountClient accountClient;
	
	public Order getOrderById(Long id) {
		return orderMapper.selectById(id);
	}

	@Override
	public void updateAccount() {
		accountClient.update();
	}

	@Override
	public void updateOrder(Order order) {
		orderMapper.updateById(order);
		accountClient.update();
	}
}
